from absl import app, flags

from coin.exchange.kr_rest.order.order_impl import generate_private_client

FLAGS = flags.FLAGS

flags.DEFINE_string('market_type', 'Spot', 'market_type')
flags.DEFINE_string('exchange', None, 'exchange name')
flags.DEFINE_string('api_version', None, 'api_version')
flags.DEFINE_string('product', None, 'product')
flags.DEFINE_bool('verbose', None, 'verbose')
flags.DEFINE_string('key_file', None, 'key_file')


def main(_):
  order = generate_private_client(FLAGS.market_type,
                                  FLAGS.exchange,
                                  FLAGS.api_version,
                                  FLAGS.key_file)
  product = order.ProductType(FLAGS.product)

  while (True):
    try:
      x = order.query_fills(product)
      if FLAGS.verbose:
        print(x.msg)
    except Exception as e:
      print("exception", e)


if __name__ == "__main__":
  app.run(main)
